<template>
    <div>
        <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/index/home' }" class="index">首页</el-breadcrumb-item>
        </el-breadcrumb>
        
        <el-row class="margintop20">
            <el-col >
                <el-carousel 
                    class="myswiper">
                    <el-carousel-item v-for="(item,i) in banner" :key="i">
                        <div class="mydiv">
                            <img :src="item.imgUrl" alt="">
                            <h4 class="text">{{item.text}}</h4>
                        </div>
                    </el-carousel-item >
                </el-carousel>
            </el-col>
        </el-row>
    </div>
</template>
<script>
import {gethomebanner} from "@/api"
import {mapState,mapMutations} from "vuex"

export default {
    data(){
        return {
            // banner:[]
        }
    },
    computed:{
     ...mapState(['banner'])
    },
    methods:{
     ...mapMutations(['changeBanner'])
    },
   
    mounted(){
           gethomebanner()
            .then(res=>{
                if(res.type){
                    // this.banner = res.result;
                    this.changeBanner(res.result)
                    
                }
            })
        
    }
}
</script>

<style lang="scss">
.el-breadcrumb__inner{
    font-size: 20px;
    font-weight: bold;
    color: #F56C6C;
}
.el-carousel__container{
    height: 450px;
}
.myswiper{
    width:100%;
    .mydiv{
        width:100%;
        position: relative;
        height:300px;
        img{
            width:100%;
            height:450px;

        }
        .text{
            position: absolute;
            width:100%;
            height:300px;
            top:20px;
            left:0;
            font-size: 30px;
            color:#fff;
            display: flex;
            justify-content: center;
            
        }
    }
}
</style>